home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / VLN_20 / MULDIV.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-30  |  3KB  |  110 lines

  1. Program MiscOps;    { find roots  }
  2.  
  3.  
  4. uses    wincrt, windos, lnk23;
  5.  
  6. const ln10ln2 = 3.3219; { exponent multiplier for 2^n vs 10^n}
  7. {$I vlnconst.inc}
  8. var
  9.      i, key  : integer;
  10.      CountMax,StdVLNSize : integer;
  11.      a, b, c, d, e, f, qt, er, rm     : integer; { pointers to the numbers }
  12.      m, n, p, q     : integer;
  13.      longLSB : longint;
  14.      vlnGroup : array[0..99] of integer;
  15.      Done : boolean;
  16.  
  17. {=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\}
  18. procedure WriteHexReg( r : integer; S : String );
  19.   const HexA : String =('0123456789ABCDEF');
  20.   var c, i, n : integer;
  21.       S1 : String[6];
  22.       w  : word;
  23.   begin
  24.   Write(S);
  25.   c := getcount(r);
  26.   while c>0 do
  27.     begin
  28.        w := GetWord(r,c);
  29.        dec(c);
  30.        S1 := '-    -';
  31.        for i := 1 to 4 do
  32.          begin
  33.            n := w and $F;
  34.            w := w shr 4;
  35.            S1[6-i] := HexA[n+1];
  36.          end;
  37.        write(' ',c,'>',S1,' ');
  38.     if   (c mod 4 = 0) then writeln;
  39.     end;
  40.  
  41.  end;
  42. {=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\}
  43. procedure WriteReg( r : integer; S : String );
  44. var
  45.     mplyer : integer;
  46. begin
  47.   mplyer := 0;
  48.   Write(S);
  49.   if getcount(r) > 0 then
  50.           write ( '[',mplyer,']',DivByBillion(r):9,'  '  );
  51.  
  52.   while  getcount(quotient) > 0  do begin
  53.              { quotient is put into this reg }
  54.           inc(mplyer,9);
  55.           if (mplyer mod 36 = 0) then
  56.              begin
  57.                writeln;
  58.                write(' >>');
  59.              end;
  60.           write ( '[',mplyer,']',DivByBillion(quotient):9,'  ' );
  61.          end;
  62.  
  63.   writeln;
  64. end;
  65.  
  66. {=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\}
  67. {             Main                   }
  68. {=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\}
  69.  var  itr, fst, loop, sgn : integer;
  70.  
  71.  begin
  72.  
  73.     Randomize;
  74.     OpenTempRegs;
  75.  
  76.  
  77.     CountMax := Getwksize div 4;      { set count to anyvalue <= wksize }
  78.     StdVLNSize := CountMax*2+6; {these variables need this much storage }
  79.  
  80.     a:= 11; b := 22; c:= 36; d := 49; e := 52; f := 16;
  81.     f := 2000;
  82.  
  83.        Number_Op(c,SetRandom,190);
  84.        WriteReg(c,'Random Number # 1   ');
  85.        writeln(getcount(c));
  86.  
  87.        Number_Op(d,SetRandom,117);
  88.        WriteReg(d,'Random Number # 2   ');
  89.        writeln(getcount(c));
  90.  
  91.        Register_Op(e,Copy,c);
  92.        Register_Op(e,MulBy,d);
  93.        WriteReg(e,'Product   ');
  94.        writeln(getcount(e));
  95.  
  96.        Register_Op(e,DivBy,d);
  97.        WriteReg(c,'Quotient   ');
  98.  
  99.  
  100.  
  101.  
  102.  
  103.     writeln('--------------------------------');
  104.     writeln('Done!');
  105.  
  106.  
  107.  
  108.    CloseTempRegs;
  109.  
  110.   end.